package com.colourclash.fruitopia.views 
{
	import com.colourclash.fruitopia.resources.EmbeddedAssets;
	import com.colourclash.fruitopia.utils.Global;
	import flash.display.Bitmap;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	/**
	 * Displays the blender in the lower right corner
	 * Clicking it destroys all fruit
	 * Can be used 3 times
	 * 
	 * @author Patrick Hammond
	 */
	public class BlenderView extends Sprite
	{
		private var _blenderCount:int = 1;
		
		public function BlenderView() 
		{
			addChild(new EmbeddedAssets.Blender1() as Bitmap);
			x = 410 * Global.getInstance().getScale();
			y = 615 * Global.getInstance().getScale();
			
			scaleX = scaleY = Global.getInstance().getScale();
			
			addEventListener(MouseEvent.CLICK, blenderClickHandler, false, 0, true);
		}
		
		private function blenderClickHandler(e:MouseEvent):void 
		{
			_blenderCount++;
			if (_blenderCount < 5)
			{
				removeChildAt(0);
				addChild(new EmbeddedAssets['Blender' + String(_blenderCount)]() as Bitmap);
				
				dispatchEvent(new Event(Event.COMPLETE, true));
			}
		}
		
	}

}